package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

/**
 * The AddressCtr class handels the information from the UI.
 * 
 * @author (Gruppe B) 
 * @version (1.0)
 */
public class AddressCtr
{
    /**
     * Instance variabels.
     */
    private AddressBook addressBook;
    
    /**
     * Constructor for the AddressCtr.
     */
    public AddressCtr()
    {
        addressBook = addressBook.getInstance();    
    }
    
    /**
     * Returns a persons information.
     */
    public void getPerson(int id)
    {
        addressBook.readPerson(id);
    }    
    
    /**
     * Creates a person and adds it to the arraylist in the addressBook.
     */
    public void createPerson(String name, String address, String postalCode, String city, String phone)
    {   
        Person person = new Person(name, address, postalCode, city, phone);
        addressBook.addPerson(person);
    }
    
    /**
     * Deletes a person form the arraylist in addressBook.
     */
    public void deletePerson(int id)
    {
        addressBook.deletePerson(id);
    }
    
    /**
     * Updates the information about a specific person using its id.
     */
    public void updatePerson(int id, String name, String address, String postalCode, String city, String phone)
    {
        addressBook.updatePerson(id, name, address, postalCode, city, phone);
    }
    
    /**
     * Prints out a list of all the people and their information in the arraylist.
     */
    public void listAllPersons()
    {
          addressBook.listPersons();
    }
}
